package cn.vin.web;

import cn.vin.dao.user.PeopleDao;
import org.apache.commons.lang3.RandomUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

/**
 * @Author: Wu Shenzhuang
 * @Date: 2019/5/5 12:31
 */
@RestController
@RequestMapping("/user")
public class UserController {
    Logger logger = LoggerFactory.getLogger(this.getClass());
    @Resource
    private PeopleDao peopleDao;
    int i = 0;
    int a = 0;
    @RequestMapping("/test")
    public void selectTest() {
        int j = i++;
        System.out.println(j +"_开始时间" + System.currentTimeMillis() / 1000);
        System.out.println(peopleDao.selectTest());
        System.out.println(j +"_结束时间" + System.currentTimeMillis() / 1000);
    }

    @RequestMapping("/test2")
    public void selectTest2() throws InterruptedException {
        int j = a++;
        System.out.println(j +"_开始时间" + System.currentTimeMillis() / 1000);
        Thread.sleep(3000);
        System.out.println(j +"_结束时间" + System.currentTimeMillis() / 1000);
    }

    @RequestMapping("/test3")
    public String test3() throws InterruptedException {
        Thread.sleep(RandomUtils.nextInt(100,1000));
        return "OK";
    }
}
